package com.hxm.appGenealogy.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hxm.appGenealogy.config.ParmIntended;
import com.hxm.appGenealogy.entity.Photo;
import com.hxm.appGenealogy.entity.PhotoVo;
import com.hxm.appGenealogy.entity.ResponDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@CrossOrigin
@RestController
@RequestMapping("app/photo")
public class PhotoController {

   /* @Autowired
    private PhotoMapper photoMapper;

    @PostMapping("selectimage")
    public ResponDataVo selectImage(@RequestBody PhotoVo photoVo){
        String parmAnalysis = ParmIntended.parmAnalysis(photoVo, "familyId","current","sizes");
        if(parmAnalysis!=null){
            return new ResponDataVo(parmAnalysis);
        }
        Page page = new Page();
        page.setCurrent(photoVo.getCurrent());
        page.setSize(photoVo.getSizes());
        LambdaQueryWrapper<Photo> photoLambdaQueryWrapper = new LambdaQueryWrapper<>();
        photoLambdaQueryWrapper.eq(Photo::getFamilyId,photoVo.getFamilyId()).orderByDesc(Photo::getTime);
        Page page1 = photoMapper.selectMapsPage(page, photoLambdaQueryWrapper);
        Map<String,Object> stringObjectMap = new HashMap<>();
        stringObjectMap.put("total",page1.getTotal());
        List<String> stringList = new ArrayList<>();
        List <Map<String,Object>>records = page1.getRecords();
        for (Map<String, Object> record : records) {
            String iamge = (String)record.get("iamge");
            stringList.add(iamge);
        }
        stringObjectMap.put("photoList",stringList);
        return new ResponDataVo(stringObjectMap);
    }*/
}
